/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package db.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 *
 * @author jerre
 */
@NamedQueries(
{
    @NamedQuery (
        name="findGPByUsername",
        query="SELECT gp FROM GP gp WHERE gp.username = :username"
    )
})
@Entity
public class GP implements Serializable {
    /**********
     * FIELDS *
     **********/

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(unique=true, nullable = false)
    private String username;

    @Column(nullable = false)
    private String password;

    private String name;

    private String surname;

    private ArrayList<String> patients = new ArrayList<String>();

    //dit hierboven moet iets worden als
    // @ManyToMany
    // private List<Patient> patients = new ArrayList<Patient>();
    //
    //

    /**************
     * CONSTRUCTORS
     **************/

    public GP(){

    }

    public GP(String username, String password){
        this.username = username;
        this.password = password;
    }

    public GP(String username, String password, String name, String surname){
        this.username = username;
        this.password = password;
        this.name = name;
        this.surname = surname;
    }

    /***********
     * METHODS *
     ***********/

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public List<String> getPatients() {
        return patients;
    }

    public void setPatients(ArrayList<String> patients) {
        this.patients = patients;
    }

    public void addPatient(String patientID) {
        patients.add(patientID);
    }

    public void removePatient(String patientID) {
        patients.remove(patientID);
    }
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GP)) {
            return false;
        }
        GP other = (GP) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "db.entities.GP[id=" + id + "]";
    }

}
